extends HBoxContainer


func init():
	Global.clearChildNode(self)
	
	for itemTypeConfig in ConfigClasses.ItemTypeConfig.configs:
		var inst = Global.createSceneInst(Consts.RESOURCE_UI_ITEMTYPE_ICON)
		add_child(inst)
		inst.init(itemTypeConfig)
		

func select(type):
	for index in range(get_child_count()):
		var childNode = get_child(index)
		if childNode.config.type == type:
			childNode.onMouseLeftButtonPressed()
			

func selectFirst():
	if get_child_count() > 0:
		get_child(0).onMouseLeftButtonPressed()


func onSelectItemType(sender, config):
	for index in range(get_child_count()):
		var childNode = get_child(index)
		if sender == childNode:
			childNode.setSelected(true)
		else:
			childNode.setSelected(false)
	Inventory.currentItemTypeTab = config.type
	Inventory.onSelectItemType(sender, config)
